package com.benio.ycfdisplayer.fresco;

import android.graphics.Bitmap;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

/**
 * Created by zhangzhibin on 2017/3/24.
 */
public class CloseableImageViewTarget extends CloseableViewTarget<ImageView> {

    public CloseableImageViewTarget(ImageView view) {
        super(view);
    }

    @Override
    protected void setDrawableInto(Drawable drawable, ImageView view) {
        view.setImageDrawable(drawable);
        if (drawable instanceof AnimationDrawable) {
            ((AnimationDrawable) drawable).start();
        }
    }

    @Override
    protected void setBitmapInto(Bitmap bitmap, ImageView view) {
        view.setImageBitmap(bitmap);
    }
}
